package IO流.序列化流;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

public class 不确定的多个对象 {
    public static void main(String[] args) throws IOException {
        //1.序列化多个对象
        Student s1=new Student("张三",23,"南京");
        Student s2=new Student("李四",24,"重庆");
        Student s3=new Student("王五",25,"成都");

        //2.序列化对象
        ArrayList<Student> arr=new ArrayList<>();
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("F//c.txt"));
        //把对象添加到集合中
        Collections.addAll(arr,s1,s2,s3);
       //序列化集合
        oos.writeObject(arr);

        //3.释放资源
        oos.close();
    }
}
